<template>
	<z-paging ref="paging" class="paging" defaultPageSize='10' v-model="dataList" @query="getIndex">
		<!-- <view class="container"> -->
		<view class="content">
			<u-swiper bgColor="#f8f8f8" keyName="image" previousMargin="0" nextMargin="0" :list="swiperList"></u-swiper>
			<u-notice-bar direction="column" keyName="title" :text="noticeList"></u-notice-bar>

			<view class="list">
				<view class="item" @click="onDetail(item)" v-for="(item, index) in projectList" :key="index">
					<view class="left">
						<text>{{ item.title }}</text>
						<text>{{ item.startTime + ' - ' + item.endTime }}</text>
					</view>
					<text :class="[item.status == 0 ? 'star' : 'have']">{{ item.statusName }}</text>
				</view>
				<!-- <u-empty :show="projectList.length < 1" mode="list" icon="http://cdn.uviewui.com/uview/empty/list.png"></u-empty> -->
			</view>

		</view>
	</z-paging>
</template>

<script>
	// import config from '@/http/config.js';
	export default {
		data() {
			return {
				swiperList: [],
				noticeList: [],
				projectList: [],
				dataList: []
			};
		},
		onLoad() {
			// this.getIndex();
		},
		onPullDownRefresh() {
			// this.getIndex();
		},
		filters: {
			statusFilter(e) {
				const info = {
					0: '未开始',
					1: '进行中',
					2: '已结束'
				};
				return info[e];
			}
		},
		methods: {
			getIndex(page, size) {
				if (page == 1) {
					this.projectList = []
				}
				this.$api.getProjectList({
					pageNum: page,
					pageSize: size
				}).then((response) => {
					this.projectList.push(...response.rows)
					this.$refs.paging.complete(response.rows);
				})
			},
			onDetail(e) {
				var nowTime = new Date()
				var endTime = new Date(e.endTime)
				console.log(nowTime)
				console.log(endTime)
				console.log(nowTime > endTime)
				if (nowTime >= endTime) {
					uni.$u.toast('竞标已结束')
					return
				} 
				console.log(`/pagesB/project/projecInfo?id=${e.id}`)
				this.$tool.to(`/pagesB/project/projecInfo?id=${e.id}`)
				// uni.navigateTo({
				// 	url: `/pages/home/detail/index?id=${e.id}`
				// });
				// const starTime = Date.parse(e.start_time)
				// const endTime = Date.parse(e.end_time)
				// const nowTime = Date.now()
				// if (starTime > nowTime) {
				// 	uni.$u.toast('竞标尚未未开始')
				// 	return
				// }
				// if (nowTime > endTime) {
				// 	uni.$u.toast('竞标已结束')
				// 	return
				// }
				// if (nowTime < endTime && nowTime > starTime) {

				// }
			}
		}
	};
</script>

<style lang="scss" scoped>
	.content {
		padding: 20rpx;

		/deep/ .u-notice-bar {
			margin: 20rpx 0;
		}

		.list {
			border-radius: 10rpx;
			background-color: #fff;
			padding: 20rpx;

			.item {
				display: flex;
				justify-content: space-between;
				align-items: center;
				font-size: 26rpx;
				color: #333;
				padding: 20rpx 0;
				border-bottom: 1rpx dotted #ddd;

				.left {
					display: flex;
					flex-direction: column;
					width: 580rpx;

					>text:last-of-type {
						margin-top: 6rpx;
						font-size: 24rpx;
						color: #999;
					}
				}

				.star {
					color: #f9ae3d;
				}

				.have {
					color: #5ac725;
				}
			}
		}
	}
</style>